﻿@{Lang lang = ViewBag.Lang;}
<style>
    
</style>
<div class="left f-result" id="flighresult">
    <div id="OutBound" class="left">
        <h2 class="sub-title">
            @lang.OUTBOUND
        </h2>
        <p class="f-des">
            @lang.FROM <b class="f-city">@ViewData["fromcity"]</b> @lang.TO <b class="f-city">@ViewData["tocity"]</b>
            <br />@lang.FLIGHTDATE <b class="f-des-time">@(((DateTime)(ViewData["DatePickerDepartDate"])).ToString("MM/yyyy"))</b>
            <br />
        </p>
        <p>
            + <b style="color: red">Chú ý:</b> Giá vé chỉ mang tính chất tham khảo
        </p>
        <style>
            .othertime
            {
                text-align: center;
            }
            .othertime .currenttime, .othertime span:hover
            {
                cursor: pointer;
                background-color: #D61321;
                font-size: 13px;
                color: White;
            }
            .othertime span
            {
                font-weight: bold;
                font-size: 13px;
                width: 90px;
                background-color: lavender;
                display: inline-block;
            }
            .filterByAirline
            {
                display: none;
            }
        </style>
        <p class="othertime">
            @{
                DateTime dtTemp = (DateTime)ViewData["DatePickerDepartDate"];
            }
            <span>@dtTemp.AddMonths(-3).ToString("MM/yyyy")</span> <span>@dtTemp.AddMonths(-2).ToString("MM/yyyy")</span>
            <span>@dtTemp.AddMonths(-1).ToString("MM/yyyy")</span> <span class="currenttime">@dtTemp.ToString("MM/yyyy")</span>
            <span>@dtTemp.AddMonths(1).ToString("MM/yyyy")</span> <span>@dtTemp.AddMonths(2).ToString("MM/yyyy")</span>
            <span>@dtTemp.AddMonths(3).ToString("MM/yyyy")</span>
        </p>
        <div class="clear">
        </div>
        @model IEnumerable<TGVR_Project.Models.ComparePriceModel>
        @(Html.Telerik().Chart(Model)
    .Name("TheFirstWay")
    .Title(title => title
                .Text("Biểu đồ giá vé trong tháng " + dtTemp.ToString("MM/yyyy"))
        .Visible(ViewBag.ShowTitle)
    )
    .Legend(legend => legend
        .Position(ViewBag.LegendPosition)
        .Visible(ViewBag.ShowLegend)
    )
    .SeriesDefaults(series =>
    {
        series.Bar().Stack(ViewBag.Stack);
        series.Column().Stack(ViewBag.Stack);
        series.Line()
              .Labels(labels => labels.Format("{0:#,##0}").Visible(false).Rotation(90))
              .Stack(ViewBag.Stack);
        series.VerticalLine()
              .Labels(labels => labels.Format("${0:#,##0}").Position(ChartLineLabelsPosition.Right).Visible(true))
              .Stack(ViewBag.Stack);
        series.Area().Stack(ViewBag.Stack);
        series.VerticalArea().Stack(ViewBag.Stack);
    })
    .Series(series =>
    {
        if (ViewBag.SeriesType == "bar")
        {
            series.Bar("VietJetPrice").Name("VietJet Airline");
            series.Bar(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "column")
        {
            series.Column("VietJetPrice").Name("VietJet Airline");
            series.Column(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "line")
        {
            series.Line("VietJetPrice").Name("VietJet Airline")
                .Markers(markers => markers.Type(ChartMarkerShape.Circle));
            series.Line(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");

        }
        else if (ViewBag.SeriesType == "area")
        {
            series.Area(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Area("VietJetPrice").Name("VietJet Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "verticalLine")
        {
            series.VerticalLine("VietJetPrice").Name("VietJet Airline")
                .Markers(markers => markers.Type(ChartMarkerShape.Circle));
            series.VerticalLine(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "verticalArea")
        {
            series.VerticalArea(s => s.JetstarPrice).Name("Jetstar Airline");
            series.VerticalArea("VietJetPrice").Name("VietJet Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
    })
    .CategoryAxis(axis => axis
        .Categories(s => s.DateString)
    )
    .ValueAxis(axis => axis
        .Numeric().Labels(labels => labels.Format("{0:#,##0} vnd"))
    )
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0:#,##0} vnd")
    )
    .DataBinding(dataBinding => dataBinding
                .Ajax().Select("_FirstLook", "testchart",
                            new
                            {
                                fromcity = ViewData["fromcity"],
                                tocity = ViewData["tocity"],
                                DatePickerDepartDate = ViewData["DatePickerDepartDate"],
                                DatePickerReturnDate = ViewData["DatePickerReturnDate"]
                            })
    )
    .HtmlAttributes(new { style = "width: 900px; height: 400px;" })
        .ClientEvents(e => e.OnDataBinding("showProgress"))
)
        <script>
            function onSeriesClick() {
                alert("onSeriesClick");
            }
            function showProgress(e) {
                $(".loadding").show();
                $("<div class='my-loading'> <img alt='loadding' style='margin: 125px 380px;' class='left' src='/Content/Images/Site/ajax_loader_red_128.gif' /></div>").insertBefore(this.firstChild);
                $(".btnMore").hide();
                //var_dump(e);
            }
        </script>
    </div>
    @if (ViewData["DatePickerReturnDate"] != null)
    {
        <div id="InBound" class="left">
            <h2 class="sub-title">
                @lang.INBOUND
            </h2>
            <p class="f-des">
                @lang.FROM <b class="f-city">@ViewData["tocity"]</b> @lang.TO <b class="f-city">@ViewData["fromcity"]</b>
                <br />@lang.FLIGHTDATE <b class="f-des-time">@(((DateTime)(ViewData["DatePickerReturnDate"])).ToString("MM/yyyy"))</b>
                <br />
            </p>
            <p class="othertime">
                @{
        dtTemp = (DateTime)ViewData["DatePickerReturnDate"];
                }
                <span>@dtTemp.AddMonths(-3).ToString("MM/yyyy")</span> <span>@dtTemp.AddMonths(-2).ToString("MM/yyyy")</span>
                <span>@dtTemp.AddMonths(-1).ToString("MM/yyyy")</span> <span class="currenttime">@dtTemp.ToString("MM/yyyy")</span>
                <span>@dtTemp.AddMonths(1).ToString("MM/yyyy")</span> <span>@dtTemp.AddMonths(2).ToString("MM/yyyy")</span>
                <span>@dtTemp.AddMonths(3).ToString("MM/yyyy")</span>
            </p>
            @(Html.Telerik().Chart(Model)
    .Name("chart1")
    .Title(title => title
        .Text("Biểu đồ giá vé trong tháng " + dtTemp.ToString("MM/yyyy"))
        .Visible(ViewBag.ShowTitle)
    )
    .Legend(legend => legend
        .Position(ViewBag.LegendPosition)
        .Visible(ViewBag.ShowLegend)
    )
    .SeriesDefaults(series =>
    {
        series.Bar().Stack(ViewBag.Stack);
        series.Column().Stack(ViewBag.Stack);
        series.Line()
              .Labels(labels => labels.Format("${0:#,##0}").Visible(false))
              .Stack(ViewBag.Stack);
        series.VerticalLine()
              .Labels(labels => labels.Format("${0:#,##0}").Position(ChartLineLabelsPosition.Right).Visible(true))
              .Stack(ViewBag.Stack);
        series.Area().Stack(ViewBag.Stack);
        series.VerticalArea().Stack(ViewBag.Stack);
    })
    .Series(series =>
    {
        if (ViewBag.SeriesType == "bar")
        {
            series.Bar("VietJetPrice").Name("VietJet Airline");
            series.Bar(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "column")
        {
            series.Column("VietJetPrice").Name("VietJet Airline");
            series.Column(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "line")
        {
            series.Line("VietJetPrice").Name("VietJet Airline")
                .Markers(markers => markers.Type(ChartMarkerShape.Circle));
            series.Line(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "area")
        {
            series.Area(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Area("VietJetPrice").Name("VietJet Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "verticalLine")
        {
            series.VerticalLine("VietJetPrice").Name("VietJet Airline")
                .Markers(markers => markers.Type(ChartMarkerShape.Circle));
            series.VerticalLine(s => s.JetstarPrice).Name("Jetstar Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
        else if (ViewBag.SeriesType == "verticalArea")
        {
            series.VerticalArea(s => s.JetstarPrice).Name("Jetstar Airline");
            series.VerticalArea("VietJetPrice").Name("VietJet Airline");
            series.Line(s => s.VietNamPrice).Name("Vietnam Airline");
        }
    })
    .CategoryAxis(axis => axis
        .Categories(s => s.DateString)
    )
    .ValueAxis(axis => axis
        .Numeric().Labels(labels => labels.Format("{0:#,##0} vnd"))
    )
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0:#,##0} vnd")
    )
            .DataBinding(dataBinding => dataBinding
                        .Ajax().Select("_FirstLook1", "testchart",
                            new
                            {
                                fromcity = ViewData["fromcity"],
                                tocity = ViewData["tocity"],
                                DatePickerDepartDate = ViewData["DatePickerDepartDate"],
                                DatePickerReturnDate = ViewData["DatePickerReturnDate"]
                            })
            )
    .HtmlAttributes(new { style = "width: 900px; height: 400px;" })
        .ClientEvents(e => e.OnDataBinding("showProgress"))
)
            <button class="btnMore" style="font-size: 14px; float: right;" onclick="onNextInBound()">@lang.READMORE</button>
        </div>
        
    }
</div>
<script>
    $('html, body').animate({
        scrollTop: $("#flighresult").offset().top
    }, 2000);

    $('#OutBound .othertime span').click(function (e) {
        $("#DatePickerDepartDate").val('01/' + $(this).text());
        $("#flightSearch").submit();
    });
    $('#InBound .othertime span').click(function (e) {
        $("#DatePickerReturnDate").val('01/' + $(this).text());
        $("#flightSearch").submit();
    });
</script>
